#include "game.h"

void Subject::Attach(Observer *o)
{
    _observers.push_back(o);
}

void Subject::Detach(Observer *o)
{
    _observers.remove(o);
}

void Subject::Notify()
{
    std::list<Observer*>::iterator i;
    for(i=_observers.begin(); i != _observers.end(); ++i)
    {
        (*i)->Update(this);
    }
}

ClockTimer::ClockTimer()
    :hour(0), minute(0), second(0)
{
    _timer = new QTimer;
    _timer->setInterval(1000);
    QObject::connect(_timer, &QTimer::timeout, this, &ClockTimer::Tick );
    _timer->start();
}

ClockTimer::~ClockTimer()
{
    _timer->stop();
    delete _timer;
}
